﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Chapter14_Lesson01
{
    class Program
    {
        static void Main(string[] args)
        {
            Type t = typeof(StringBuilder);

            ConstructorInfo ci = t.GetConstructor(new Type[] { typeof(string) });

            object o = ci.Invoke(new object[] { "hello, " });

            MethodInfo sbAppend = t.GetMethod("Append", new Type[] { typeof(string) });

            object result = sbAppend.Invoke(o, new object[] { "world!" });

            PropertyInfo pLenght = t.GetProperty("Length");

            Console.WriteLine(result);

            int value = (int) pLenght.GetValue(result, null);

            Console.WriteLine(value.ToString());

        }
    }
}
